package cn.iocoder.yudao.module.pay.transfer.mq;

import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.module.api.pay.transfer.message.TransferDealingMessage;
import cn.iocoder.yudao.module.api.pay.transfer.message.TransferFailureMessage;
import cn.iocoder.yudao.module.api.pay.transfer.message.TransferSuccessMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 转账单据 事件生产者
 *
 * @author 山野羡民（1032694760@qq.com）
 */
@Slf4j
@Component
public class TransferProducer {

    public void sendTransferSuccessMessage(String transferNo, String outTransferNo) {
        log.info("[sendTransferSuccessMessage][transferNo({}) outTransferNo({})]", transferNo, outTransferNo);
        SpringUtil.getApplicationContext().publishEvent(new TransferSuccessMessage(transferNo, outTransferNo));
    }

    public void sendTransferFailureMessage(String transferNo, String outTransferNo) {
        log.info("[sendTransferFailureMessage][transferNo({}) outTransferNo({})]", transferNo, outTransferNo);
        SpringUtil.getApplicationContext().publishEvent(new TransferFailureMessage(transferNo, outTransferNo));
    }

    public void sendTransferDealingMessage(String transferNo, String outTransferNo) {
        log.info("[sendTransferDealingMessage][transferNo({}) outTransferNo({})]", transferNo, outTransferNo);
        SpringUtil.getApplicationContext().publishEvent(new TransferDealingMessage(transferNo, outTransferNo));
    }

}
